//
//  UIButton+Extension.swift
//  WeiBo
//
//  Created by tusm on 2017/6/16.
//  Copyright © 2017年 GM. All rights reserved.
//

import UIKit

extension UIButton{
    
    /// 便利构造函数
    ///
    /// - Parameters:
    ///   - imageName: <#imageName description#>
    ///   - bgImageName: <#bgImageName description#>
    convenience init(imageName:String, bgImageName:String){
        
        self.init()
        
        setImage(UIImage(named:imageName), for: .normal)
        setImage(UIImage(named:imageName + "_highlighted"), for: .highlighted)
        setBackgroundImage(UIImage(named:bgImageName), for: .normal)
        setBackgroundImage(UIImage(named:bgImageName + "_highlighted"), for: .highlighted)
        
        sizeToFit()
    }
    
    
    
    /// 便利构造函数
    ///
    /// - Parameters:
    ///   - title: title
    ///   - imageName: imageName
    ///   - color: color
    convenience init(title:String, imageName:String, color:UIColor = UIColor.orange) {
        self.init()
        
        setTitle(title, for: .normal)
        setTitleColor(color, for: .normal)
        setBackgroundImage(UIImage(named:imageName), for: .normal)
        
    }
}
